<?php use_helper('I18N', 'Date') ?>
<?php include_partial('bb_prestamo/assets') ?>
<script type="text/javascript">
  function hide_cant_dias(){
    var id_tipo_prestamo = $('#bb_prestamo_idTipoPrestamo').val();
    if(id_tipo_prestamo == '<?php echo ReferenceTipoPrestamo::ENSALA ?>'){
      $('.sf_admin_form_field_cantidad_dias').slideUp('fast', function(){
        $('#bb_prestamo_cantidad_dias').val(1);
      });
    }
    $('.chzn-select').change(function(){
      if($(this).val() == '<?php echo ReferenceTipoPrestamo::ENSALA ?>')
      {
        $('.sf_admin_form_field_cantidad_dias').slideUp('slow', function(){
          $('#bb_prestamo_cantidad_dias').val(1);
        });
      }
      else
      {
        $('#bb_prestamo_cantidad_dias').val(null);          
        $('.sf_admin_form_field_cantidad_dias').slideDown('slow');
      }
    });
    var width = 600;
    var height = 550;
    window.parent.$('#site').dialog( "option", "width", 'auto' );
    window.parent.$('#site').dialog( "option", "height", 'auto');
    window.parent.$('#site').height( height );
    window.parent.$('#site').width( width );
    window.parent.$('#site').dialog( "option", "position", 'center' );
  }
<?php if (isset($renovacion) && $renovacion): ?>
    var persona = '<?php echo $BbPrestamo->getPersona() ?>';
    var idlibro = '<?php echo $BbPrestamo->getIdlibro() ?>';
                
    var row_template = '<div class="sf_admin_form_row sf_admin_text">'+
      '<div>'+
      '<span class="label label-info">%title%: %data%</span>'+
      '</div>'+
      '</div>';
    $(document).ready(function (){
      $('#sf_fieldset_none').prepend(row_template.replace('%title%','Persona').replace('%data%', persona)+row_template.replace('%title%','Inventario').replace('%data%', idlibro));
      hide_cant_dias();
    });
                
  </script>
<?php else: ?>
  $(document).ready(function (){
  hide_cant_dias();
  });
  </script>
<?php endif; ?>
<div id="sf_admin_container">
  <h1><?php echo $title ?></h1>

  <?php include_partial('bb_prestamo/flashes') ?>

  <div id="sf_admin_header">
    <?php include_partial('bb_prestamo/form_header', array('BbPrestamo' => $BbPrestamo, 'form' => $form, 'configuration' => $configuration)) ?>
  </div>

  <div id="sf_admin_content">
    <?php include_partial('bb_prestamo/form', array('BbPrestamo' => $BbPrestamo, 'form' => $form, 'configuration' => $configuration, 'helper' => $helper)) ?>
  </div>

  <div id="sf_admin_footer">
    <?php include_partial('bb_prestamo/form_footer', array('BbPrestamo' => $BbPrestamo, 'form' => $form, 'configuration' => $configuration)) ?>
  </div>
</div>
